<?php $__env->startSection('title','Отчеты'); ?>
<?php $__env->startSection('content'); ?>

    <div class="flex justify-between items-center">

        <h1 class="text-[#232323] text-[40px] font-medium">Отчеты</h1>
        <div class="flex gap-[10px]">
            <a href="<?php echo e(route('reports.add')); ?>" class="flex gap-[10px] bg-[#3042D0] text-white rounded-[5px] p-[15px] inline-block">
                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="21" viewBox="0 0 20 21" fill="none">
                    <path d="M11.6673 2.16663H5.00065C4.55862 2.16663 4.1347 2.34222 3.82214 2.65478C3.50958 2.96734 3.33398 3.39127 3.33398 3.83329V17.1666C3.33398 17.6087 3.50958 18.0326 3.82214 18.3451C4.1347 18.6577 4.55862 18.8333 5.00065 18.8333H15.0007C15.4427 18.8333 15.8666 18.6577 16.1792 18.3451C16.4917 18.0326 16.6673 17.6087 16.6673 17.1666V7.16663L11.6673 2.16663Z" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M11.666 2.16663V7.16663H16.666" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M10 15.5V10.5" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M7.5 13H12.5" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                </svg>
                <span>Добавить отчет</span>
            </a>
            <button type="button" id="export_button" data-url="/reports/excel"
                    class="flex gap-[10px] bg-[#EB692C] text-white rounded-[5px] p-[15px] inline-block">
                <svg xmlns="http://www.w3.org/2000/svg" width="20" height="21" viewBox="0 0 20 21" fill="none">
                    <path d="M12.5 12.1667L16.6667 8.00004L12.5 3.83337" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                    <path d="M3.33398 17.1667V11.3333C3.33398 10.4493 3.68517 9.60143 4.31029 8.97631C4.93542 8.35119 5.78326 8 6.66732 8H16.6673" stroke="white" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/>
                </svg>
                <span>
                    Экспортировать
                </span>
            </button>
        </div>
    </div>

    <div class="bg-[#ffffff] py-[30px] px-[50px] mt-[40px]">
        <form action="<?php echo e(route('reports')); ?>" method="GET" class="filter-form">
            <?php echo csrf_field(); ?>
            <?php echo method_field('GET'); ?>

            <div class="grid grid-cols-6 gap-x-[20px] gap-y-[30px]">
                <div class="col-span-2 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Центр</h2>
                    <div class="flex flex-col gap-[20px]">
                        <select name="filters[centers_id][]" id="" multiple>
                            <?php $__currentLoopData = $centers; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $center): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <div class="flex justify-between flex-row-reverse">
                                    <option
                                        value="<?php echo e($center->id); ?>" <?php if(in_array($center->id,request('filters.centers_id') ?? [])): echo 'selected'; endif; ?>><?php echo e($center->name); ?></option>
                                </div>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>


                </div>
                <div class="col-span-2 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Инструктор</h2>

                    <div class="flex flex-col gap-[20px]">
                        <select name="filters[instructors_id][]" id="" multiple>
                            <?php $__currentLoopData = $instructors; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $instructor): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                <option
                                    value="<?php echo e($instructor->id); ?>" <?php if(in_array($instructor->id,request('filters.instructors_id') ?? [])): echo 'selected'; endif; ?>>
                                    <?php echo e($instructor->name); ?> <?php echo e($instructor->second_name); ?>

                                </option>

                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>
                </div>
                <div class="col-span-1 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Месяц</h2>

                    <div class="flex flex-col gap-[20px]">

                        <select name="filters[months][]" id="" multiple>
                            <?php $__currentLoopData = $months; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $month): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option
                                    value="<?php echo e($month); ?>" <?php if(in_array($month,request('filters.months') ?? [])): echo 'selected'; endif; ?>><?php echo e($month); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>


                    </div>
                </div>
                <div class="col-span-1 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Год</h2>

                    <div class="flex flex-col gap-[20px]">

                        <select name="filters[year][]" id="" multiple>
                            <?php $__currentLoopData = range(2019, (int)date("Y")); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $year): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option
                                    value="<?php echo e($year); ?>" <?php if(in_array($year,request('filters.year') ?? [])): echo 'selected'; endif; ?>><?php echo e($year); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>

                        </select>

                    </div>
                </div>
                <div class="col-span-2 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Заболевание</h2>

                    <div class="flex flex-col gap-[20px]">

                        <select name="filters[diagnosis][]" id="" multiple>
                            <?php $__currentLoopData = $sickness; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sicknes): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option
                                    value="<?php echo e($sicknes->name); ?>" <?php if(in_array($sicknes->name,request('filters.diagnosis') ?? [])): echo 'selected'; endif; ?>><?php echo e($sicknes->name); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>
                    </div>


                </div>
                <div class="col-span-2 flex gap-[5px] flex-wrap flex-col">
                    <h2 class="filter__title">Программа занятий</h2>

                    <div class="flex flex-col gap-[20px]">
                        <select name="filters[lessons][]" id="" multiple>
                            <?php $__currentLoopData = $programs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $program): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                <option
                                    value="<?php echo e($program); ?>" <?php if(in_array($program,request('filters.lessons') ?? [])): echo 'selected'; endif; ?>><?php echo e($program); ?>

                                </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        </select>

                    </div>


                </div>
                <div class="col-span-2 flex items-end">
                    <input type="submit" value="Фильтровать" class="font-bold uppercase w-full bg-[#ffffff] border bordere-solid border-[#23232333] text-[232323] p-[15px] rounded-[5px]">
                </div>
            </div>



        </form>

    </div>
    <div class="mt-[30px]">

        <div class="bg-[#ffffff] rounded-[15px] py-[30px] px-[50px] pb-[50px]">
            <h2 class="text-2xl font-bold">Суммарная статистика</h2>
            <div class="mt-[30px]">
                <table class="table__statistics"  cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr class="table__statistics--header">
                        <td colspan="5">Занимавшихся</td>
                        <td colspan="3">Часы</td>
                        <td colspan="4">Платно</td>
                        <td colspan="4">Бесплатно</td>
                    </tr>
                    <tr class="table__statistics--bottom">
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Всего
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['membersAll']); ?>

                                </div>
                            </div>

                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    3-18 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members318']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    19-55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members1955']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    > 55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members55']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Нет возраста
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['membersNo']); ?>

                                </div>
                            </div>
                        </td>


                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Всего
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['allLessons']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Платно
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['payLessons']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Бесплатно
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['freeLessons']); ?>

                                </div>
                            </div>
                        </td>


                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    3-18 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members318pay']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    19-55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members1955pay']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    > 55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members55pay']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Нет возраста
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['membersNopay']); ?>

                                </div>
                            </div>
                        </td>


                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    3-18 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members318free']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    19-55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members1955free']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    > 55 л
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['members55free']); ?>

                                </div>
                            </div>
                        </td>
                        <td>
                            <div class="bottom__item">
                                <div class="bottom__item--top">
                                    Нет возраста
                                </div>
                                <div class="bottom__item--bottom">
                                    <?php echo e($statistics['membersNofree']); ?>

                                </div>
                            </div>
                        </td>



                    </tr>
                    </tbody>
                </table>

            </div>

        </div>

        <?php if(count($reports) != 0): ?>

            <table class="w-full my-[50px]" id="export_table">
                <tbody>
                <tr class="result-top">
                    <th class="result-top__item">#</th>
                    <th class="result-top__item">Месяц</th>
                    <th class="result-top__item">Год</th>
                    <th class="result-top__item">программа занятий</th>
                    <th class="result-top__item">Центр</th>
                    <th class="result-top__item">Участник</th>
                    <th class="result-top__item">Болезнь</th>
                    <th class="result-top__item">инструктор</th>
                    <th class="result-top__item"> за счет каких грантов/субсидий</th>
                    <th class="result-top__item">возрастная группа</th>
                    <th class="result-top__item">всего часов</th>
                    <th class="result-top__item">платно часов</th>
                    <th class="result-top__item">бесплатно часов</th>
                    <th class="result-top__item">Действия</th>
                </tr>
                <?php $__currentLoopData = $reports; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $report): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                    <tr class="result-bottom">
                        <td class=""><?php echo e($key + 1); ?></td>
                        <td class=""><?php echo e($report->months); ?></td>
                        <td class=""><?php echo e($report->year); ?></td>
                        <td class=""><?php echo e($report->lessons); ?></td>
                        <td class=""><?php echo e($report->center->name); ?></td>
                        <td class=""><?php echo e($report->member->fullname); ?></td>
                        <td class=""><?php echo e($report->member->diagnosis); ?></td>
                        <td class=""><?php echo e($report->instructor->second_name); ?> <?php echo e($report->instructor->name); ?> <?php echo e($report->instructor->surname); ?></td>
                        <td class=""><?php echo e($report->grants); ?></td>
                        <td class="">

                            <?php
                                $birthday = new DateTime($report->member->birthday);
                                   $interval = $birthday->diff(new DateTime);

                            ?>
                            <?php if($interval->y >= 3 && $interval->y <= 18 ): ?>
                                3-18 л
                            <?php elseif($interval->y >= 19 && $interval->y <= 55): ?>
                                19-55 л
                            <?php elseif($interval->y > 55): ?>
                                > 55 л
                            <?php elseif($interval->y <= 0): ?>
                                Нет возраста
                            <?php endif; ?>


                        </td>
                        <td class=""><?php echo e((int)$report->pay_lessons + (int)$report->free_lessons); ?> </td>
                        <td class=""><?php echo e($report->pay_lessons); ?></td>
                        <td class=""><?php echo e($report->free_lessons); ?></td>
                        <td class="">
                            <div class="flex items-center justify-between">
                                <a href="<?php echo e(route('reports.edit', $report->id)); ?>" class="p-2">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="25" viewBox="0 0 24 25" fill="none">
                                        <g opacity="0.3">
                                            <path fill-rule="evenodd" clip-rule="evenodd" d="M2.79081 5.29081C3.29716 4.78446 3.98392 4.5 4.7 4.5H11C11.4971 4.5 11.9 4.90294 11.9 5.4C11.9 5.89706 11.4971 6.3 11 6.3H4.7C4.4613 6.3 4.23239 6.39482 4.0636 6.5636C3.89482 6.73239 3.8 6.9613 3.8 7.2V19.8C3.8 20.0387 3.89482 20.2676 4.0636 20.4364C4.23239 20.6052 4.46131 20.7 4.7 20.7H17.3C17.5387 20.7 17.7676 20.6052 17.9364 20.4364C18.1052 20.2676 18.2 20.0387 18.2 19.8V13.5C18.2 13.0029 18.6029 12.6 19.1 12.6C19.5971 12.6 20 13.0029 20 13.5V19.8C20 20.5161 19.7155 21.2028 19.2092 21.7092C18.7028 22.2155 18.0161 22.5 17.3 22.5H4.7C3.98392 22.5 3.29716 22.2155 2.79081 21.7092C2.28446 21.2028 2 20.5161 2 19.8V7.2C2 6.48392 2.28446 5.79716 2.79081 5.29081Z" fill="black"/>
                                            <path fill-rule="evenodd" clip-rule="evenodd" d="M19.2894 4.23683C19.0311 4.23683 18.7835 4.33942 18.6008 4.52204L10.521 12.6019L10.062 14.438L11.8981 13.979L19.978 5.89916C20.1606 5.71654 20.2632 5.46886 20.2632 5.2106C20.2632 4.95234 20.1606 4.70466 19.978 4.52204C19.7953 4.33942 19.5477 4.23683 19.2894 4.23683ZM17.3727 3.29392C17.8811 2.78558 18.5705 2.5 19.2894 2.5C20.0083 2.5 20.6977 2.78558 21.2061 3.29392C21.7144 3.80225 22 4.4917 22 5.2106C22 5.92949 21.7144 6.61895 21.2061 7.12728L12.9562 15.3772C12.8449 15.4885 12.7054 15.5675 12.5527 15.6056L9.07905 16.4741C8.78312 16.548 8.47007 16.4613 8.25437 16.2456C8.03867 16.0299 7.95196 15.7169 8.02595 15.4209L8.89436 11.9473C8.93254 11.7946 9.01149 11.6551 9.12279 11.5439L17.3727 3.29392Z" fill="black"/>
                                        </g>
                                    </svg>
                                </a>
                                <form action="<?php echo e(route('reports.delete', $report->id)); ?>" method="POST">
                                    <?php echo csrf_field(); ?>
                                    <?php echo method_field('DELETE'); ?>
                                    <button type="submit" class="p-2">
                                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="25" viewBox="0 0 24 25" fill="none">
                                            <g opacity="0.3">
                                                <path d="M3 6.5H5H21" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                                                <path d="M19 6.5V20.5C19 21.0304 18.7893 21.5391 18.4142 21.9142C18.0391 22.2893 17.5304 22.5 17 22.5H7C6.46957 22.5 5.96086 22.2893 5.58579 21.9142C5.21071 21.5391 5 21.0304 5 20.5V6.5M8 6.5V4.5C8 3.96957 8.21071 3.46086 8.58579 3.08579C8.96086 2.71071 9.46957 2.5 10 2.5H14C14.5304 2.5 15.0391 2.71071 15.4142 3.08579C15.7893 3.46086 16 3.96957 16 4.5V6.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                                                <path d="M10 11.5V17.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                                                <path d="M14 11.5V17.5" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                                            </g>
                                        </svg>
                                    </button>
                                </form>
                            </div>
                        </td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>


                </tbody>
            </table>


            <?php echo e($reports->withQueryString()->links()); ?>

        <?php else: ?>
            <h1 class="text-2xl font-bold mt-[50px]">Данные не найдены</h1>
    <?php endif; ?>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layout.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /var/www/fastuser/data/www/lk.ligamechty.ru/resources/views/reports/show.blade.php ENDPATH**/ ?>